package com.hopedove.workshop.data

class WorkshopUserSessionManager {
    private var userSession: WorkshopUserSession? = null

    fun getUserSession(): WorkshopUserSession? = userSession

    fun login(info: WorkshopUserInfo, rewrite: Boolean = false) {
        if (userSession != null && !rewrite) {
            throw IllegalStateException("User has already logged in!")
        }

        userSession = WorkshopUserSession(info)
    }

    fun logout() {
        userSession = null
    }

}

class WorkshopUserSession(private val userInfo: WorkshopUserInfo) {
    val userId = userInfo.id
    val userName = userInfo.realName
}

data class WorkshopUserInfo(
    val id: String,
    val employeeNo: String,
    val accountName: String,
    val realName: String,
)